
%union {
	int intval;
	char * strval;
	int subtok;
}

%token IDENTIFIER
%token STRING
%token INTNUM HEXNUM

%token ABOUT ACCOUNT AFK AGENCY AREA ARRANGE ASK ASSIGNMENTS ATTACK AUTOLOOT
%token AWARDS BACKGROUND BAN BOUNTY BUG BUY CALLCONTROL CAST CHANNEL CHARACTER
%token CHECK CHOWN CLIENT CLIMB CLONE CLOSE COMMANDS CONSIDER COOLDOWNS COORDINATES 
%token COVER CREATE CROUCH DB DELETE DESCRIBE DESTROY DISBAND DISCONNECT
%token DOING DOOR DOSSIER DOWN DRAW DROP DUEL DUMP EAST EDIT EFFECTS EMOTES EMOTETO
%token ENTER ENTRANCES EQUIP EXAMINE EXITS FAQ FEAT FINGER FRIENDS FOLLOW GET GIVE
%token GIVEITEM GO GRAB HELP HISTORY HOLD HOLSTER IDEA IGNORE INVENTORY INVITE
%token JUMP KILL LAST LEAVE LIST LISTEN LOAD LOCATE LOCK LOG LOOK MAIL ME MEMORY
%token MESSAGE MODULE MOTD MUTANT NEWS NORTH NPC OBJECT OCCUPATION OPEN
%token PASSWD PICK PROFESSION PUSH PUT QUEUES QUIT RECITE RECRUIT READ REBOOT
%token REGHELPER RELOAD REMOVE REPAIR REST ROOM RUN SOUTH SAVE SAY SEARCH SEEN 
%token SELL SEND SET SHOUT SHUTDOWN SKILL SHOW SIT SOCIALS SPELLS STAND STATS
%token TABLES TAKE TASKS TEAM TELEPORT TELL THROW TRAIN TRAIT TURN UP
%token UNLOAD UNLOCK UNWIELD UPTIME USERS VALUE VERSION WEST WAIT WALL WALLOPS
%token WEAPON WEAR WHO WHOIS WIELD ADD JOIN RESET MOVE CONTENTS TARGET FIND
%token MAN JARGON
%token N S E W U D 
%token HERB POLTICE KIT AMMO TRASH SCRATCH ARMOR
%token IMPROVISED AXE MACE SWORD SPEAR NUNCHUK KNIFE KNUCKLES CLUB EXOTIC_MELEE
%token HANDGUN ASSAULT_RIFLE BOLT_RIFLE SNIPER_RIFLE SHOTGUN SUBMACHINEGUN
%token MACHINEGUN EXPLOSIVE HURLED EXOTIC_RANGED
%token A AN THE ON OF ABOVE BELOW UNDER IN TO ACROSS AGAINST AT BEFORE BEHIND
%token BENEATH BESIDE BETWEEN BY FROM INTO UPON INSIDE
%token ALL SOME FEW NONE AND BUT

%%

nlp_command: predicate_command | command_command | communicate_command
	;

predicate_command:
	predicate |	/* look */
	predicate direct_object | /* look book */
	predicate prep_phrase direct_object | /* look at the book */
	predicate determiner direct_object | /* look the book */
	predicate direct_object prep_phrase object | /* take book from the shelf */
	predicate determiner direct_object prep_phrase object | /* take the book from the shelf */
	predicate quantity direct_object |	/* take all rings */
	predicate quantity direct_object conjunction object | /* take all rings but silver */
	predicate_command conjunction predicate_command
	;
	
predicate:
	ASK | ATTACK | BUY | CAST | CLIMB | COVER | CROUCH | DRAW | DROP |
	DUEL | EMOTETO | ENTER | EQUIP | EXAMINE | FOLLOW | GET | GIVE | 
	GO | GRAB | HOLD | HOLSTER | INVITE | JUMP | LEAVE | LOCK | LOOK |
	ME | OPEN | PICK | PUSH | PUT | RECITE | READ | REMOVE | REPAIR |
	SELL | SHOUT | SHOW | SIT | STAND | TAKE | THROW |
	TURN | UNLOAD | UNLOCK | UNWIELD | WEAR | WIELD
	;
	
direct_object: IDENTIFIER
	;
	
prep_phrase:
	ON | ON THE | OF | OF THE | ABOVE | ABOVE THE | BELOW | BELOW THE |
	UNDER | UNDER THE | IN | IN THE | TO | TO THE | ACROSS | ACROSS THE |
	AGAINST | AGAINST THE | AT | AT THE | BEFORE | BEFORE THE | BEHIND |
	BEHIND THE | BENEATH | BENEATH THE | BESIDE | BESIDE THE | BETWEEN |
	BETWEEN THE | BY | BY THE | FROM | FROM THE | INTO | INTO THE |
	UPON | UPON THE | UP | UP THE | INSIDE | INSIDE THE
	;
	
determiner:
	A | AN | THE
	;

object: IDENTIFIER
	;
	
quantity:
	ALL | SOME | A FEW | NONE
	;

conjunction:
	AND | BUT 
	;

communicate_command:
	IDENTIFIER ',' predicate_command
	;

command_command: no_arg_cmd | one_arg_cmd | two_arg_cmd | three_arg_cmd |
	four_arg_cmd
	;

no_arg_cmd:
	ABOUT | ACCOUNT | AFK | AGENCY | ASSIGNMENTS | AUTOLOOT | AWARDS | BACKGROUND |
	BUG | CALLCONTROL | CHARACTER | COMMANDS | COOLDOWNS | COORDINATES |
	DISBAND | DOSSIER | DOWN | EAST | D | E | EFFECTS | EMOTES |
	ENTRANCES | EXITS | FAQ | FRIENDS | HELP | HISTORY | IDEA | INVENTORY |
	LAST | LISTEN | LOG | MAIL | MOTD | NEWS | NORTH | N | OCCUPATION |
	PROFESSION | QUIT | REBOOT | REST | SOUTH | S | SAVE | SHUTDOWN | 
	SOCIALS | SPELLS | STATS | TASKS | TEAM | TRAIN | UP | U | TITLE |
	UPTIME | USERS | VERSION | WEST | W | WHO | REGHELPER | JARGON
	;

one_arg_cmd:
	AFK string_list | BAN IDENTIFIER | CHANNEL LIST | ASSIGNMENTS REMOVE IDENTIFIER |
	CONSIDER IDENTIFIER | DESCRIBE string_list | ASSIGNMENTS LIST IDENTIFIER |
	DOING string_list | DUMP DB | DUMP STATS | DUMP MEMORY | FINGER IDENTIFIER |
	IGNORE IDENTIFIER | INVITE IDENTIFIER | LIST TABLES | LIST QUEUES |
	LOCATE IDENTIFIER | MAIL CREATE | MAIL LIST | NEWS ADD | NEWS DELETE |
	PASSWD IDENTIFIER | RECRUIT IDENTIFIER | REBOOT string_list | SEEN IDENTIFIER |
	SHUTDOWN string_list | SKILL IDENTIFIER | TELEPORT IDENTIFIER | TRAIT IDENTIFIER |
	WAIT IDENTIFIER | WALL string_list | WALLOPS string_list | WHOIS IDENTIFIER |
	SAY string_list | TITLE LIST | SHOP LIST | DOOR LIST | HELP IDENTIFIER |
	HELP CONTENTS | FEAT LIST | FEAT IDENTIFIER |FIND LIST | LOCATE LIST |
	FIND IDENTIFIER | LOCATE IDENTIFIER | RUN IDENTIFIER | man IDENTIFIER |
	JARGON string_list
	;

two_arg_cmd:
	AREA CREATE IDENTIFIER | AREA DESTROY IDENTIFIER | BOUNTY IDENTIFIER INTNUM |
	CHANNEL JOIN IDENTIFIER | CHANNEL CREATE IDENTIFIER | CHANNEL EDIT IDENTIFIER |
	CHANNEL CLOSE IDENTIFIER | CLIENT DISCONNECT IDENTIFIER | CLIENT EXAMINE IDENTIFIER |
	FRIENDS ADD IDENTIFIER | FRIENDS DELETE IDENTIFIER | MESSAGE SEND IDENTIFIER |
	MODULE RELOAD IDENTIFIER | MODULE LOAD IDENTIFIER | MODULE UNLOAD IDENTIFIER |
	NPC CREATE IDENTIFIER | NPC DELETE IDENTIFIER | ROOM CREATE IDENTIFIER |
	ROOM DELETE IDENTIFIER | AGENCY CREATE IDENTIFIER | AGENCY DELETE IDENTIFIER
	OBJECT DESTROY IDENTIFIER | OBJECT CLONE IDENTIFIER | NPC CLONE IDENTIFIER |
	TELL IDENTIFIER string_list | AREA LIST IDENTIFIER | TITLE SET IDENTIFIER |
	BAN IDENTIFIER string_list | SHOP OWNER IDENTIFIER | SHOP DEPOSIT INTNUM |
	SHOP WITHDRAW INTNUM | CHARACTER CREATE IDENTIFIER | CHARACTER DELETE IDENTIFIER |
	DOOR DELETE IDENTIFIER 	| FEAT IDENTIFIER IDENTIFIER | MAIL READ INTNUM |
	MAIL DELETE INTNUM | MAIL SEND IDENTIFIER
	;
	
three_arg_cmd:
	CLIENT IDENTIFIER RESET PASSWD | NPC MOVE IDENTIFIER IDENTIFIER |
	GIVEITEM IDENTIFIER INTNUM IDENTIFIER | WEAPON CREATE wpn_type IDENTIFIER |
	OBJECT CREATE obj_type IDENTIFIER | SHOP SELL IDENTIFIER FOR INTNUM |
	SHOP BUY obj_type FOR INTNUM | SHOP BUY wpn_type FOR INTNUM | 
	DOOR CREATE IDENTIFIER direction | FRIENDS NOTE IDENTIFIER string_list
	;
	
four_arg_cmd:
	AGENCY IDENTIFIER SET IDENTIFIER string_list | AREA IDENTIFIER SET IDENTIFIER string_list |
	CHANNEL IDENTIFIER SET IDENTIFIER string_list | DOOR IDENTIFIER SET IDENTIFIER string_list |
	NPC IDENTIFIER SET IDENTIFIER string_list | WEAPON IDENTIFIER SET IDENTIFIER string_list |
	OBJECT IDENTIFIER SET IDENTIFIER string_list
	;
	
string_list : IDENTIFIER | IDENTIFIER string_list
	;

obj_type:
	HERB | POLTICE | KIT | AMMO | TRASH | SCRATCH
	;
	
wpn_type:
	IMPROVISED | AXE | MACE | SWORD | SPEAR | NUNCHUK | KNIFE | KNUCKLES |
	CLUB | EXOTIC_MELEE | HANDGUN | ASSAULT_RIFLE | BOLT_RIFLE | SNIPER_RIFLE |
	SHOTGUN | SUBMACHINEGUN | MACHINEGUN | EXPLOSIVE | HURLED | EXOTIC_RANGED
	;
	
direction:
	NORTH | SOUTH | EAST | WEST | UP | DOWN
	;

%%
	
	
	
	
	
